package com.zzyl.mapper;

import com.zzyl.dto.BedDto;
import com.zzyl.dto.BedDtoId;
import com.zzyl.entity.Bed;
import com.zzyl.vo.BedVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BedMapper {

    List<BedVo> getBedsByRoomId(Long roomId);

    /**
     * 新增床位
     *
     * @return
     */
    void createBed(Bed bed);

    /**
     * 根据id查询房间信息
     *
     * @param id
     * @return
     */
    Bed selectById(Integer id);

    /**
     * 根据id修改床位信息
     *
     * @return
     */
    void updateBedId(BedDto bed);

    /**
     * 根据id删除床位信息
     *
     * @param id
     */
    @Delete("delete from bed where id = #{id};")
    void deleteBed(Long id);

    @Select("select * from bed where bed_number = #{bedNumber};")
    Bed selectByNumber(String bedNumber);

    @Select("select count(*) from bed where bed_number = #{bedNumber} and id != #{id} ;")
    Integer selectByNumberId(String bedNumber, Long id);
}

